public class Application {

    @RequestMapping("/")
    @ResponseBody

    public static void main(String[] args) throws Exception 
    {
        String zresult=new String();
        for(int i=1;i<=2015;i++)
            zresult=zresult.concat(String.valueOf(i));
        //System.out.println(zresult);
        BigInteger bi=new BigInteger(zresult);
        bi=bi.remainder(new BigInteger(new String("9")));
        System.out.println(bi);
    }
}